//可使用 express.Router 类创建模块化、可挂载的路由句柄。
var express = require('express');
var router = express.Router();
//ajax
var superagent = require('superagent')

router.get('/userInfo',function (req,res,next) {
    //获得参数 get>query post>body
    // var response = {'username':req.query.username,'password':req.query.password}
    superagent.get('http://localhost:80/user/userInfo')
        .set('Cookie',req.headers.cookie)
        .end(function (err,response) {
            if(err){console.log(err.status+err.message);next();}
            else{
                res.send(JSON.stringify(response.body));
                next();
            }
        });
});

module.exports = router;